package main

import (
	"fmt"
	"runtime"
	"sync"
)

func main() {
	//	runtime.GOMAXPROCS(4)
	//	exit := make(chan int)

	//	go func() {
	//		defer close(exit)
	//		go func() {
	//			fmt.Println("b")
	//		}()
	//	}()

	//	for i := 0; i < 10; i++ {
	//		fmt.Println("a:", i)
	//		if i == 4 {
	//			runtime.Gosched() //切换任务
	//		}
	//	}
	//	<-exit

	runtime.GOMAXPROCS(2)

	var wg sync.WaitGroup
	wg.Add(2)
	fmt.Println("Starting go Routines")

	go func() {
		defer wg.Done()

		for char := 'a'; char < 'a'+26; char++ {
			fmt.Printf("%c", char)
		}
	}()

	go func() {
		defer wg.Done()
		for number := 1; number < 27; number++ {
			fmt.Printf("%d", number)
		}
	}()

	fmt.Println("Waiting to Finish")
	wg.Wait()

	fmt.Printf("\n Terminating Program")
}
